//
//  HYDataCheckTableViewCell.m
//  TJHYHardwareProduct
//
//  Created by Kendama on 2018/1/23.
//  Copyright © 2018年 Kendama. All rights reserved.
//

#import "HYDataCheckTableViewCell.h"
#import "NSMutableAttributedString+FIDText.h"
@implementation HYDataCheckTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)updateDataWithTitleArray:(NSArray *)titleArray data:(NSArray *)dataArray
{
    _dateLabel.text = dataArray.firstObject;
    NSArray *labelArray = @[self.tempLabel,self.smogLabel,self.voltageLabel,self.electricityLabel];
    for (int i = 0; i < titleArray.count; i++)
    {
        UILabel *label = labelArray[i];
        NSString *string = [NSString stringWithFormat:@"%@:   ",titleArray[i]];
        NSString *value = [NSString stringWithFormat:@"%@",dataArray[i+1]];
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
        [attributedString attributeStrings:@[string,value] attributes:@[@[rgba(175,175,175,1),fontWithSize(15)],@[rgba(51,51,51,1),fontWithSize(15)]]];
        label.attributedText = attributedString;
    }
    
}

#pragma mark --- 懒加载
- (UILabel *)dateLabel
{
    if(!_dateLabel)
    {
        UIView *superView = self.contentView;
        _dateLabel = [[UILabel alloc]init];
        [superView addSubview:_dateLabel];
//        [_dateLabel setFont:<#(UIFont * _Nullable)#>];
        [_dateLabel setTextColor:rgba(1,71,141,1)];
    }
    return _dateLabel;
}
- (UIImageView *)lineImageView
{
    if(!_lineImageView)
    {
        UIView *superView = self.contentView;
        _lineImageView = [[UIImageView alloc]init];
        [superView addSubview:_lineImageView];
        _lineImageView.image = [UIImage imageNamed:@"line_image"];
    }
    return _lineImageView;
}
- (UILabel *)tempLabel
{
    if(!_tempLabel)
    {
        UIView *superView = self.contentView;
        _tempLabel = [[UILabel alloc]init];
        [superView addSubview:_tempLabel];
        [_tempLabel setFont:fontWithSize(15)];
//        [_tempLabel setTextColor:<#(UIColor * _Nullable)#>];
    }
    return _tempLabel;
}
- (UILabel *)voltageLabel
{
    if(!_voltageLabel)
    {
        UIView *superView = self.contentView;
        _voltageLabel = [[UILabel alloc]init];
        [superView addSubview:_voltageLabel];
        [_voltageLabel setFont:fontWithSize(15)];
//        [_voltageLabel setTextColor:<#(UIColor * _Nullable)#>];
    }
    return _voltageLabel;
}
- (UILabel *)smogLabel
{
    if(!_smogLabel)
    {
        UIView *superView = self.contentView;
        _smogLabel = [[UILabel alloc]init];
        [superView addSubview:_smogLabel];
        [_smogLabel setFont:fontWithSize(15)];
//        [_smogLabel setTextColor:<#(UIColor * _Nullable)#>];
    }
    return _smogLabel;
}
- (UILabel *)electricityLabel
{
    if(!_electricityLabel)
    {
        UIView *superView = self.contentView;
        _electricityLabel = [[UILabel alloc]init];
        [superView addSubview:_electricityLabel];
        [_electricityLabel setFont:fontWithSize(15)];
//        [_electricityLabel setTextColor:<#(UIColor * _Nullable)#>];
    }
    return _electricityLabel;
}

#pragma mark -- 布局
- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    CGFloat edge = px1920Height(30);
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(edge);
        make.left.mas_equalTo(superView.mas_left).with.offset(edge);
    }];
    
    [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(20));
        make.right.mas_equalTo(superView.mas_right).with.offset(px1080Width(20));
        make.top.mas_equalTo(_dateLabel.mas_bottom).with.offset(edge);
    }];
    
    [self.tempLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_lineImageView.mas_bottom).with.offset(edge);
        make.left.mas_equalTo(_dateLabel.mas_left);
    }];
    
    [self.smogLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_tempLabel.mas_top);
        make.left.mas_equalTo(superView.mas_centerX);
    }];
    
    [self.voltageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_tempLabel.mas_bottom).with.offset(edge);
        make.left.mas_equalTo(_tempLabel.mas_left);
    }];
    
    [self.electricityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_smogLabel.mas_left);
        make.top.mas_equalTo(_voltageLabel.mas_top);
    }];
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
